package com.tico.translatereditor.service.impl;

import com.tico.common.service.impl.AbstractService;
import com.tico.common.utils.BaseQuery;
import com.tico.common.utils.QueryResult;
import com.tico.translatereditor.domain.TranslaterData;
import com.tico.translatereditor.mapper.TranslaterDataMapper;
import com.tico.translatereditor.service.TranslaterDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 */
@Service
public class TranslaterDataServiceImpl extends AbstractService<TranslaterData> implements TranslaterDataService {


   @Autowired
   TranslaterDataMapper translaterDataMapper;

   @Override
   public TranslaterData findById(Serializable id) {
     return translaterDataMapper.findById(id);
   }

    @Override
    public int insertBatch(List<TranslaterData> translaterDatas) {
      return translaterDataMapper.insertBatch(translaterDatas);
    }
    @Override
    public int update(TranslaterData translaterDatas) {
      return translaterDataMapper.update(translaterDatas);
    }

    @Override
    public int insert(TranslaterData translaterData) {
      return translaterDataMapper.insert(translaterData);
    }
    @Override
    public List<TranslaterData > findByNamedParamList(Map<String,Object> param){
        return translaterDataMapper.findByNamedParamList(param);
    }

    @Override
    public int delete(Serializable id) {
      return translaterDataMapper.delete(id);
    }

    @Override
    public int remove(Serializable id) {
      return translaterDataMapper.remove(id);
    }

    @Override
    public QueryResult<TranslaterData> findPageInfo(BaseQuery baseQuery) {
        QueryResult<TranslaterData> result = new QueryResult<TranslaterData>();
        result.setQuery(baseQuery);
        Map
        <String, Object> params = result.getQuery().build();
        Integer amount = this.translaterDataMapper.countPageInfo(params);
        result.setTotalRecord(amount);
        if (amount == 0) {
        return result;
        }
        List<TranslaterData> list = translaterDataMapper.findPageInfo(params);
        if (!CollectionUtils.isEmpty(list)) {
        result.setResultList(list);

        }
        return result;
    }
}
